<?php
abstract class CV_Datastore_Builder_Form extends CV_Object{
	private $_type_html_map = array(
		'single-line-text' => 'text',
		'multi-line-text' => 'textarea',
/*		'set' => 'textarea',
		'enum' => 'radio',
		'date' => 'text',
		'time' => 'text'*/
	);
	private $_field_html_map = array();
	public function __construct( $class, $current_values = NULL ){
		$this->_fields = array();
		$this->class = $class;
		foreach( $class->get_fields() as $field ){
			if( !$field->is_protected ){
				$this->_fields[$field->get_name()] = new CV_Datastore_Builder_Form_Yaml_Field( $this, $field );
			}
		}
		$this->current_values = $current_values;
	}
	public function is_submitted(){
		return !empty($_POST);
	}
	public function is_valid(){
		return true;
	}
	function get_result(){
		$class = $this->class->get_name();
		return new $class( $_POST );
	}		
	function render(){
		return $this->_render();
	} 
	abstract function _render( $field = NULL, $view = 'form' );
}